// NOTE: Exceptions.h included in Common.h
#include <Kharlia/Core/Common.h>
//#include <Kharlia/Core/Exceptions.h>

namespace kharlia { namespace core { namespace exc {

//static PyTypeObject _KharliaNativeExceptionType {
//    PyObject_HEAD_INIT(NULL)
//    0,
//    "kharlia.core.KharliaNativeException",
//    sizeof(PyBaseExceptionObject),
//    0,
//    ((PyTypeObject*)PyExc_BaseException)->tp_dealloc,
//    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
//    PyDoc_STR("Base class for Kharlia native exceptions"),
//    (traverseproc)((PyTypeObject*)PyExc_BaseException)->tp_traverse,
//    (inquiry)((PyTypeObject*)PyExc_BaseException)->tp_clear,
//    0, 0, 0, 0, 0, 0, 0,
//    PyExc_Exception,
//    0, 0, 0,
//    offsetof(PyBaseExceptionOffset, dict),
//    (initproc)((PyTypeObject*)PyExc_BaseException)->tp_init,
//    0,
//    ((PyTypeObject*)PyExc_BaseException)->tp_new,
//};
//
//PyObject* KharliaNativeException = (PyObject*)&_KharliaNativeExceptionType;

static void Translate_Exception(Exception const& e) {
    boost::format f("(native %2%): %1%");
    f % e.what();
    f % e.GetTypeName();
    PyErr_SetString(e.GetPyExcType(), f.str().c_str());
}

static void Translate_PythonException(PythonException const& e) {
    boost::format f("(native): %1%");
    f % e.what();
    PyErr_SetString(e.GetPyExcType(), f.str().c_str());
}

void _InitExceptions() {
    KH_REG_EXC(Exception)
    KH_REG_EXC(PythonException)
}

}}}